package com.questionGenerator.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.questionGenerator.dto.req.AddQuestionReqDTO;
import com.questionGenerator.dto.req.QuestionReqDTO;
import com.questionGenerator.dto.resp.QuestionRespDTO;
import com.questionGenerator.service.QuestionService;
import com.questionGenerator.vo.UnifyResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: usagi
 * @Date: 2024/04/18/23:29
 * @Description:
 */
@RestController
@RequestMapping("/question/")
public class QuestionController {
    @Autowired
    public QuestionService questionService;
    @PostMapping("/getQuestionByCondition")
    public UnifyResponseVO<IPage<QuestionRespDTO>>  getQuestionList(@RequestBody QuestionReqDTO questionReqDTO){
        return new UnifyResponseVO("200",questionService.queryQuestionByCondition(questionReqDTO));
    }
    @GetMapping("/getCountByKnowledgePoint")
    public UnifyResponseVO<Integer> getCountByKnowledgePoint(@RequestParam String knowledgePoint){
        return new UnifyResponseVO<>("200",questionService.queryCountByKnowledgePoint(knowledgePoint));
    }
    @GetMapping("/getCountByLanguage")
    public UnifyResponseVO<Integer> getCountByLanguage(@RequestParam String language){
        return new UnifyResponseVO<>("200",questionService.queryCountByLanguage(language));
    }
    @GetMapping("/getCountByTypeId")
    public UnifyResponseVO<Integer> getCountByTypeId(@RequestParam Integer id){
        return new UnifyResponseVO<>("200",questionService.queryCountByTypeId(id));
    }
    @PostMapping("/addNewQuestion")
    public UnifyResponseVO<Boolean> addNewQuestion(@RequestBody AddQuestionReqDTO addQuestionReqDTO){
        return new UnifyResponseVO<>("200",questionService.addNewQuestion(addQuestionReqDTO));
    }
}
